/*-----------------------------------------------File Info------------------------------------------------
** File Name:               bspExti.c  
** Last modified date:      20220724
** Last version:            V0.1
** Description:             
*/

#ifndef __BSP_EXTI_H_
#define __BSP_EXTI_H_

#include <stdint.h>
#include <stdio.h>

#include "bspConfig.h"

typedef void (*extiCallback)(void);


#if BSP_MCU_TYPE == BSP_MCU_GD32E23x	
typedef struct 
{
	rcu_periph_enum gpioRcu;	//RCU_GPIOx	
	uint32_t gpioPeriph;		//GPIOx
	uint32_t pin;				//GPIO_PIN_x
	uint32_t pull;				//GPIO_PUPD_NONE,GPIO_PUPD_PULLUP,GPIO_PUPD_PULLDOWN
	
	uint8_t nvicIrq;			//EXTI0_1_IRQn,EXTI2_3_IRQn,EXTI4_15_IRQn
    uint8_t nvicIrqPriority;	//0~3
	uint8_t exti_port; 			//EXTI_SOURCE_GPIOx
	uint8_t exti_pin;			//EXTI_SOURCE_PINx
	exti_line_enum linex;		//EXTI_x
	exti_trig_type_enum trig_type;   //EXTI_TRIG_RISING,EXTI_TRIG_FALLING,EXTI_TRIG_BOTH,EXTI_TRIG_NONE
	
}tsCfgExti;

#elif BSP_MCU_TYPE == BSP_MCU_GD32F3x0		
typedef struct 
{
	rcu_periph_enum gpioRcu;	//RCU_GPIOAx	
	uint32_t gpioPeriph;		//GPIOx
	uint32_t pin;				//GPIO_PIN_x
	uint32_t pull;				//GPIO_PUPD_NONE,GPIO_PUPD_PULLUP,GPIO_PUPD_PULLDOWN
	
	uint8_t nvicIrq;			//EXTI0_1_IRQn,EXTI2_3_IRQn,EXTI4_15_IRQn
    uint8_t nvicIrqPriority;	//0~2
	uint8_t nvicIrqSubPriority;	//0~2
	uint8_t exti_port; 			//EXTI_SOURCE_GPIOx
	uint8_t exti_pin;			//EXTI_SOURCE_PINx
	exti_line_enum linex;		//EXTI_x
	exti_trig_type_enum trig_type;   //EXTI_TRIG_RISING,EXTI_TRIG_FALLING,EXTI_TRIG_BOTH,EXTI_TRIG_NONE
}tsCfgExti;
#endif

#define extiA0	{RCU_GPIOA,GPIOA,GPIO_PIN_0,GPIO_PUPD_PULLUP,\
				EXTI0_1_IRQn,3,EXTI_SOURCE_GPIOA,EXTI_SOURCE_PIN0,EXTI_0,EXTI_TRIG_BOTH}

				
extern void extiConfig(tsCfgExti *cfg, extiCallback cb);				
extern void extiDisableInt(tsCfgExti *cfg);		
extern void extiEnsableInt(tsCfgExti *cfg);	

				
#endif	//__BSP_EXTI_H_
				
				
		


				
				